package com.example.controller.student;

import com.example.common.Result;
import com.example.entity.DTO.StudentDetailDTO;
import com.example.service.student.InfoService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 学生信息
 */

@RestController
@RequestMapping("/student")
public class InfoController {

    @Resource
    private InfoService infoService;

    /**
     * 更新学生信息
     */
    @PutMapping("/updateInfo")
    public Result update(@RequestBody StudentDetailDTO student) {
        infoService.update(student);
        return Result.success();
    }

    /**
     * 获取学生详细信息
     */
    @GetMapping("/getInfo/{username}")
    public Result getInfo(@PathVariable String username) {
        StudentDetailDTO studentDetailDTO = infoService.selectStudentDetailByUsername(username);
        return Result.success(studentDetailDTO);
    }
}
